package person.bing.fbcloud.brushQuestions.thread.WaitNotify;

/**
 * 消费者线程
 * @author: mengfanbing
 * @date: 2020/5/28 11:35
 */
public class Consumer implements Runnable {
    @Override
    public void run() {
        while (true){
            if (Depository.getStock() <= 0){
                try {
                    wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            Integer reduce = Depository.reduce();
            System.out.println("已消费，库存="+reduce);
            notifyAll();
        }
    }
}
